.dropdown {
  --combobox-padding: 4px;
  padding: var(--combobox-padding);

  &:has([data-mantine-scrollbar]) {
    .search {
      max-width: calc(100% + var(--combobox-padding));
    }
  }

  &[data-composed] {
    padding-inline-end: 0;
  }

  &[data-hidden] {
    display: none;
  }
}

/* Variables must be both on dropdown and options to support usage of Combobox.Options without Combobox.Dropdown */
.dropdown,
.options {
  --combobox-option-padding-xs: 4px 8px;
  --combobox-option-padding-sm: 6px 10px;
  --combobox-option-padding-md: 8px 12px;
  --combobox-option-padding-lg: 10px 16px;
  --combobox-option-padding-xl: 14px 20px;
  --combobox-option-padding: var(--combobox-option-padding-sm);
}

.option {
  padding: var(--combobox-option-padding);
  font-size: var(--combobox-option-fz, var(--mantine-font-size-sm));
  border-radius: var(--mantine-radius-default);
  background-color: transparent;
  color: inherit;
  cursor: pointer;
  overflow-wrap: break-word;

  &:where([data-combobox-selected]) {
    background-color: var(--mantine-primary-color-filled);
    color: var(--mantine-color-white);
  }

  &:where([data-combobox-disabled]) {
    cursor: not-allowed;
    opacity: 0.35;
  }

  @mixin hover {
    &:where(:not([data-combobox-selected], [data-combobox-disabled])) {
      @mixin where-light {
        background-color: var(--mantine-color-gray-0);
      }

      @mixin where-dark {
        background-color: var(--mantine-color-dark-7);
      }
    }
  }
}

.search {
  margin-inline: calc(var(--combobox-padding) * -1);
  margin-top: calc(var(--combobox-padding) * -1);
  width: calc(100% + var(--combobox-padding) * 2);
  border-top-width: 0;
  border-inline-width: 0;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  margin-bottom: var(--combobox-padding);
  position: relative;

  &,
  &:focus {
    @mixin where-light {
      border-color: var(--mantine-color-gray-2);
    }

    @mixin where-dark {
      border-color: var(--mantine-color-dark-4);
    }
  }

  @mixin where-light {
    background-color: var(--mantine-color-white);
  }

  @mixin where-dark {
    background-color: var(--mantine-color-dark-7);
  }
}

.empty {
  font-size: var(--combobox-option-fz, var(--mantine-font-size-sm));
  text-align: center;
  padding: var(--combobox-option-padding);
  color: var(--mantine-color-dimmed);
}

.header,
.footer {
  font-size: var(--combobox-option-fz, var(--mantine-font-size-sm));
  border: 0 solid transparent;
  margin-inline: calc(var(--combobox-padding) * -1);
  padding: var(--combobox-option-padding);

  @mixin where-light {
    border-color: var(--mantine-color-gray-2);
  }

  @mixin where-dark {
    border-color: var(--mantine-color-dark-4);
  }
}

.footer {
  border-top-width: 1px;
  margin-top: var(--combobox-padding);
  margin-bottom: calc(var(--combobox-padding) * -1);
}

.header {
  border-bottom-width: 1px;
  margin-bottom: var(--combobox-padding);
  margin-top: calc(var(--combobox-padding) * -1);
}

.group {
  &:has(.groupLabel:only-child) {
    display: none;
  }
}

.groupLabel {
  color: var(--mantine-color-dimmed);
  font-size: calc(var(--combobox-option-fz, var(--mantine-font-size-sm)) * 0.85);
  padding: var(--combobox-option-padding);
  font-weight: 500;
  position: relative;
  display: flex;
  align-items: center;

  &::after {
    content: '';
    flex: 1;
    inset-inline: 0;
    height: 1px;
    margin-inline-start: var(--mantine-spacing-xs);

    @mixin where-light {
      background-color: var(--mantine-color-gray-2);
    }

    @mixin where-dark {
      background-color: var(--mantine-color-dark-4);
    }
  }

  &:only-child {
    display: none;
  }
}

/* ------- Combobox.Chevron ------- */
.chevron {
  --combobox-chevron-size-xs: 14px;
  --combobox-chevron-size-sm: 18px;
  --combobox-chevron-size-md: 20px;
  --combobox-chevron-size-lg: 24px;
  --combobox-chevron-size-xl: 28px;
  --combobox-chevron-size: var(--combobox-chevron-size-sm);

  @mixin where-light {
    --_combobox-chevron-color: var(--combobox-chevron-color, var(--mantine-color-gray-6));
  }

  @mixin where-dark {
    --_combobox-chevron-color: var(--combobox-chevron-color, var(--mantine-color-dark-3));
  }

  width: var(--combobox-chevron-size);
  height: var(--combobox-chevron-size);
  color: var(--_combobox-chevron-color);

  &:where([data-error]) {
    color: var(--combobox-chevron-color, var(--mantine-color-error));
  }
}

/* ------- OptionsDropdown ------- */
.optionsDropdownOption {
  display: flex;
  align-items: center;
  gap: 8px;

  &:where([data-reverse]) {
    justify-content: space-between;
  }
}

.optionsDropdownCheckIcon {
  opacity: 0.4;
  width: 0.8em;
  min-width: 0.8em;
  height: 0.8em;

  :where([data-combobox-selected]) & {
    opacity: 1;
  }
}

.optionsDropdownCheckPlaceholder {
  width: 0.8em;
  min-width: 0.8em;
  height: 0.8em;
}
